package src.com.qf.controller;

import com.alibaba.fastjson.JSON;
import src.com.qf.entity.WeiXin;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "PayController",value = "/pay")
public class PayController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("支付完成");
        String jsonStr = request.getParameter("result");
        WeiXin weiXin = JSON.parseObject(jsonStr, WeiXin.class);
        if (weiXin.getResult().getResult_code().equals("SUCCESS")){
            System.out.println("订单编号"+weiXin.getResult().getOut_trade_no());
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
